﻿using System;
using Newtonsoft.Json.Linq;
using ZYing.LiquidThemeEngine.Config.Schemas;
using ZYing.LiquidThemeEngine.Json;

namespace ZYing.LiquidThemeEngine.Config.Schemas.Json
{
    public class ThemeSettingSchemaJsonConverter : JsonCreationConverter<ThemeSettingSchema>
    {
        protected override ThemeSettingSchema Create(Type objectType, JObject jObject)
        {
            if (jObject.TryGetValue("name", out var value) && value.Type == JTokenType.String && value.Value<string>() == "theme_info")
            {
                return new ThemeSettingSchemaForThemeInfo();
            }
            return new ThemeSettingSchemaForSettings();
        }
    }
}
